<?
$PATHTOMUSIC = 'http://71.6.195.82/music/';
echo "The path to the music is: {$PATHTOMUSIC}<br />";
$PATHTOM3U = 'http://71.6.195.82/musicm3u.php';
echo "The path to the m3u is: {$PATHTOM3U}<br />";
error_reporting(E_ALL);
include('db.php');
echo "Just included the database configuration.<br />";
$time = time();
echo "Time: {$time}<br />";
$volume = '-300';
if (isset($_GET['vol'])){$volume = $_GET['vol'];}
echo "Volume is: {$volume}<br />";
$autostart = 'true';
$autostartint = '1';
if (isset($_GET['preload']) and $_GET['preload'] == '1') 
{
     $autostart = 'false';
     $autostartint = '0';
}
echo "Autostart: {$autostart}<br />";
echo "Autostart int: {$autostartint}<br />";
if (isset($_GET['song']))
{
    $song = mysql_real_escape_string($_GET['song']);
    echo "Song: {$song}<br />";
    if (substr($song,0,1) == 'p')
    {
        // It's a playlist!
        $id = substr($song,1);
        $params = '?playlist=' . $id . '&ck=' . $time;
        $mp3path = $PATHTOM3U . $params;
        echo "Its a playlist!<br />";
    }
    else
    {
        $id = (int) $song;
        $query = 'SELECT title,extension FROM songlist WHERE songid = ' . $id;
        echo "{$query}<br />";
        $result = mysql_query($query);
        $row = mysql_fetch_row($result);
        $title = $row[0];
        echo "Title: {$title}<br />";
        $extension = $row[1];
        echo "Extension: {$extension}<br />";
        $mp3path = $PATHTOMUSIC . $title . '.' . $extension;
        echo "MP3 path: {$mp3path}<br />";
    }
}
elseif (isset($_GET['jukebox']))
{
    $jukebox = $_GET['jukebox'];
    $params = '?jukebox=' . $jukebox . '&ck=' . $time;
    $mp3path = $PATHTOM3U . $params;
    echo "Jukebox much?<br />";
}
else {die('Error!');}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Music</title>
</head>
<body>
<OBJECT ID="MediaPlayer1" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab# Version=5,1,52,701" STANDBY="Loading Microsoft Windows® Media Player components..." TYPE="application/x-oleobject" width="280" height="46">
<param name="fileName" value="<?=$mp3path; ?>">
<param name="animationatStart" value="true">
<param name="transparentatStart" value="true">
<param name="autoStart" value="<?=$autostart; ?>">
<param name="showControls" value="true">
<param name="Volume" value="<?=$volume; ?>">
<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="<?=$mp3path; ?>" name="MediaPlayer1" width=280 height=46 autostart=<?=$autostartint; ?> showcontrols=1 volume=<?=$volume; ?>>
</OBJECT>
</body>
</html>